<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>文本替换</title>
    <style>textarea{width:100%}</style>
</head>
<body>
脚本:  <button onclick="repl()">转换</button> <span>结果:</span><span id="prompt"></span> <a onclick="newPage()">新窗口打开</a>
<textarea id="script" rows="12">
    s=s.replace(/as varchar/gi, "as String");
    s=s.replace(/([a-zA-Z]* +JOIN)/gi, "GLOBAL $1");
    s=s.replace(/( +in +\( *select)/gi, "GLOBAL$1");
    s=s.replace(/bi_dm_[a-z_]+./g, "");
    s=s.replace(/bi_dw_[a-z_]+./g, "");
    s=s.replace(/bi_ods_[a-z_]+./g, "");
</textarea>
文本:
<textarea id="input" rows="20">cast(pisf.SKU_UID as varchar) = cast(bb.sku_uid as varchar)</textarea>

<script>
var historyList = [];
function repl() {
    const input = document.getElementById('input').value;
    const script1 = document.getElementById('script').value;
    var script2 = 'var s = input;s=' + script1;
    var newText = eval(script2);
    if (newText) {
        document.getElementById('input').value = newText;
        historyList.push(input);
        document.getElementById('prompt').innerText = "完成! 新的大小为:" + newText.length;
    } else {
        document.getElementById('prompt').innerText = "失败";
    }
}
</script>
</body>
</html>